package com.intelli4.pos.core;

import java.math.BigDecimal;
import java.util.Calendar;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.ForeignKey;

@Entity
public class Order {
	@Id
	@Column(length = 64)
	private String id;
	@Column(length = 20)
	@Enumerated(EnumType.STRING)
	private OrderMode mode;
	@Column(length = 20)
	@Enumerated(EnumType.STRING)
	private OrderStatus status;
	@Column(nullable = false)
	@Temporal(TemporalType.TIMESTAMP)
	private Calendar startTime;
	@Column(nullable = false)
	@Temporal(TemporalType.TIMESTAMP)
	private Calendar endTime;
	@ManyToOne(optional = false, fetch = FetchType.LAZY)
	@JoinColumn(name = "sessionId")
	@ForeignKey(name = "Order_SessionFK")
	private Session session;
	@Column(length = 50, nullable = false)
	private String shiftName;
	@ManyToOne(optional = false, fetch = FetchType.LAZY)
	@JoinColumn(name = "operatorId")
	@ForeignKey(name = "Order_OperatorFK")
	private Operator operator;
	@Column(length = 20, nullable = false)
	private String operatorEmpId;
	@Column(length = 50, nullable = false)
	private String operatorFirstName;
	@Column(length = 50, nullable = false)
	private String operatorLastName;
	@ManyToOne(optional = false, fetch = FetchType.LAZY)
	@JoinColumn(name = "terminalId")
	@ForeignKey(name = "Order_TerminalFK")
	private Terminal terminal;
	@Column(length = 50, nullable = false)
	private String terminalName;
	@OneToMany(mappedBy = "order", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	private List<OrderItem> orderItems;
	@Column(nullable = false)
	private BigDecimal subtotal;
	@OneToMany(mappedBy = "order", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	private List<TaxItem> taxItems;
	@Column(nullable = false)
	private BigDecimal total;
	@OneToMany(mappedBy = "order", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	private List<Payment> payments;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public OrderMode getMode() {
		return mode;
	}

	public void setMode(OrderMode mode) {
		this.mode = mode;
	}

	public OrderStatus getStatus() {
		return status;
	}

	public void setStatus(OrderStatus status) {
		this.status = status;
	}

	public Calendar getStartTime() {
		return startTime;
	}

	public void setStartTime(Calendar startTime) {
		this.startTime = startTime;
	}

	public Calendar getEndTime() {
		return endTime;
	}

	public void setEndTime(Calendar endTime) {
		this.endTime = endTime;
	}

	public Session getSession() {
		return session;
	}

	public void setSession(Session session) {
		this.session = session;
	}

	public String getShiftName() {
		return shiftName;
	}

	public void setShiftName(String shiftName) {
		this.shiftName = shiftName;
	}

	public Operator getOperator() {
		return operator;
	}

	public void setOperator(Operator operator) {
		this.operator = operator;
	}

	public String getOperatorEmpId() {
		return operatorEmpId;
	}

	public void setOperatorEmpId(String operatorEmpId) {
		this.operatorEmpId = operatorEmpId;
	}

	public String getOperatorFirstName() {
		return operatorFirstName;
	}

	public void setOperatorFirstName(String operatorFirstName) {
		this.operatorFirstName = operatorFirstName;
	}

	public String getOperatorLastName() {
		return operatorLastName;
	}

	public void setOperatorLastName(String operatorLastName) {
		this.operatorLastName = operatorLastName;
	}

	public Terminal getTerminal() {
		return terminal;
	}

	public void setTerminal(Terminal terminal) {
		this.terminal = terminal;
	}

	public String getTerminalName() {
		return terminalName;
	}

	public void setTerminalName(String terminalName) {
		this.terminalName = terminalName;
	}

	public List<OrderItem> getOrderItems() {
		return orderItems;
	}

	public void setOrderItems(List<OrderItem> orderItems) {
		this.orderItems = orderItems;
	}

	public BigDecimal getSubtotal() {
		return subtotal;
	}

	public void setSubtotal(BigDecimal subtotal) {
		this.subtotal = subtotal;
	}

	public List<TaxItem> getTaxItems() {
		return taxItems;
	}

	public void setTaxItems(List<TaxItem> taxItems) {
		this.taxItems = taxItems;
	}

	public BigDecimal getTotal() {
		return total;
	}

	public void setTotal(BigDecimal total) {
		this.total = total;
	}

	public List<Payment> getPayments() {
		return payments;
	}

	public void setPayments(List<Payment> payments) {
		this.payments = payments;
	}
}
